#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int n,Q,c[8080];
struct eee{
	int shu,xu;
};
eee a[8080],aa;
int cmp(eee x,eee y){
	if(x.shu>y.shu)return 0;
	else if(x.shu==y.shu){
		if(x.xu>y.xu)return 0;
		else return 1;
	}
	else return 1;
}
int main(){
	freopen("sort.in","r",stdin);
	freopen("sort.out","w",stdout);
	scanf("%d%d",&n,&Q);
	for(int q=1;q<=n;q++){
		scanf("%d",&a[q].shu);
		a[q].xu=q;
	}
	sort(a+1,a+1+n,cmp);
	for(int q=1;q<=n;q++){
		c[a[q].xu]=q;
	}
	int a1,a2;
	for(int q=1;q<=Q;q++){
		scanf("%d",&a2);
		if(a2==1){
			scanf("%d",&a1);
			scanf("%d",&a[c[a1]].shu);
			while((a[c[a1]].shu>a[c[a1]+1].shu||(a[c[a1]].shu==a[c[a1]+1].shu&&a[c[a1]].xu>a[c[a1]+1].xu))&&c[a1]!=n){
				aa.shu=a[c[a1]].shu;
				a[c[a1]].shu=a[c[a1]+1].shu;
				a[c[a1]+1].shu=aa.shu;
				aa.xu=a[c[a1]].xu;
				a[c[a1]].xu=a[c[a1]+1].xu;
				a[c[a1]+1].xu=aa.xu;
				c[a[c[a1]].xu]--;
				c[a1]++;
			}
			while((a[c[a1]].shu<a[c[a1]-1].shu||(a[c[a1]].shu==a[c[a1]-1].shu&&a[c[a1]].xu<a[c[a1]-1].xu))&&c[a1]!=1){
				aa.shu=a[c[a1]].shu;
				a[c[a1]].shu=a[c[a1]-1].shu;
				a[c[a1]-1].shu=aa.shu;
				aa.xu=a[c[a1]].xu;
				a[c[a1]].xu=a[c[a1]-1].xu;
				a[c[a1]-1].xu=aa.xu;
				c[a[c[a1]].xu]++;
				c[a1]--;
			}
		}
		else{
			scanf("%d",&a1);
			printf("%d\n",c[a1]);
		}
	}
	fclose(stdin);
	fclose(stdout);
	return 0;
}
